/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cl.zeke.pizzastore.negocio.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author taller
 */
@Entity
@Table(name = "PROVEEDOR")
@NamedQueries({
    @NamedQuery(name = "Proveedor.findAll", query = "SELECT p FROM Proveedor p"),
    @NamedQuery(name = "Proveedor.findByRunProveedor", query = "SELECT p FROM Proveedor p WHERE p.runProveedor = :runProveedor"),
    @NamedQuery(name = "Proveedor.findByNombreFantasia", query = "SELECT p FROM Proveedor p WHERE p.nombreFantasia = :nombreFantasia"),
    @NamedQuery(name = "Proveedor.findByFonoContacto", query = "SELECT p FROM Proveedor p WHERE p.fonoContacto = :fonoContacto")})
public class Proveedor implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "RUN_PROVEEDOR")
    private Integer runProveedor;
    @Basic(optional = false)
    @Column(name = "NOMBRE_FANTASIA")
    private String nombreFantasia;
    @Column(name = "FONO_CONTACTO")
    private String fonoContacto;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "runProveedor", fetch = FetchType.LAZY)
    private List<Compra> compraList;

    public Proveedor() {
    }

    public Proveedor(Integer runProveedor) {
        this.runProveedor = runProveedor;
    }

    public Proveedor(Integer runProveedor, String nombreFantasia) {
        this.runProveedor = runProveedor;
        this.nombreFantasia = nombreFantasia;
    }

    public Integer getRunProveedor() {
        return runProveedor;
    }

    public void setRunProveedor(Integer runProveedor) {
        this.runProveedor = runProveedor;
    }

    public String getNombreFantasia() {
        return nombreFantasia;
    }

    public void setNombreFantasia(String nombreFantasia) {
        this.nombreFantasia = nombreFantasia;
    }

    public String getFonoContacto() {
        return fonoContacto;
    }

    public void setFonoContacto(String fonoContacto) {
        this.fonoContacto = fonoContacto;
    }

    public List<Compra> getCompraList() {
        return compraList;
    }

    public void setCompraList(List<Compra> compraList) {
        this.compraList = compraList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (runProveedor != null ? runProveedor.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Proveedor)) {
            return false;
        }
        Proveedor other = (Proveedor) object;
        if ((this.runProveedor == null && other.runProveedor != null) || (this.runProveedor != null && !this.runProveedor.equals(other.runProveedor))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.zeke.pizzastore.negocio.entities.Proveedor[ runProveedor=" + runProveedor + " ]";
    }
    
}
